package com.matrix.java.chap_17.example;

import java.io.*;

public class Case17_02 {
    public static void main(String[] args) throws IOException {
        try (DataOutputStream output =
                     new DataOutputStream(new FileOutputStream("temp.dat"))) {
            output.writeUTF("John");
            output.writeDouble(85.5);
            output.writeUTF("Jim");
            output.writeDouble(185.5);
            output.writeUTF("George");
            output.writeDouble(105.25);
        }
        try (DataInputStream input =
                     new DataInputStream(new FileInputStream("temp.dat"))) {
            System.out.println(input.readUTF() + "\t" + input.readDouble());
            System.out.println(input.readUTF() + "\t" + input.readDouble());
            System.out.println(input.readUTF() + "\t" + input.readDouble());
        }
    }
}
